package com.q.tqb.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

public class BaseFragmentPagerAdapter extends FragmentPagerAdapter {


    private String[] tabTitles;
    private Context context;
    private List<Fragment> mFragments;
    private List<String> list;

    public BaseFragmentPagerAdapter(FragmentManager fm, Context context, List<Fragment> mFragments, String[] tabTitles) {
        super(fm);
        this.context = context;
        this.mFragments = mFragments;
        this.tabTitles = tabTitles;
    }

    public BaseFragmentPagerAdapter(FragmentManager fm, Context context, List<Fragment> mFragments, List<String> list) {
        super(fm);
        this.context = context;
        this.mFragments = mFragments;
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (list != null) return list.get(position);
        return tabTitles[position];
    }
}